<template>
	<view class="content">
			<u-navbar title="我的地址" :autoBack="true":placeholder="true" >
			</u-navbar>
			<view class="address-box">
				<AddressForm :state="type" :addressList="addressList"></AddressForm>
			</view>
			<u-button type="primary" :plain="true" shape="circle" @click='addbtn'>新增地址</u-button>
			<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import addressform from '../component/addressform.vue'
	import http from '@/utils/http.js'
	export default{
		data(){
			return{
				addressList:[],
				show:false,
				type:''
			}
		},
		components:{
			AddressForm:addressform
		},
		methods:{
			addbtn(){
				uni.navigateTo({
					url:'/page_my/my-address/addaddress'
				})
			},
			async getaddlist(){
				const res = await http({
					url:'/user/address'
				})
				this.addressList = res.data
			}
		},
		onShow() {
			this.getaddlist()
			this.$bus.$on('addadd', params => {
			this.$refs.uToast.show({
				message:'删除成功'
			})
			})
		},
		onLoad(el) {
			this.type = el.type
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 0 40rpx;
	}
	.address-box{
		margin-top: 40rpx;
		height: 800rpx;
	}
	.textcolor{
		color: #CC0022;
	}
</style>